
package cn.shuangliang.contract.service;

import cn.shuangliang.contract.dao.AdminMapper;
import cn.shuangliang.contract.dao.TypeMapper;
import cn.shuangliang.contract.model.Type;
import cn.shuangliang.contract.util.MyBatisUtil;
import cn.shuangliang.contract.vo.Type2;

import java.util.List;

/**
 * @author oldliu
 * @since 1.0
 */

public class TypeService {
    //获得顶层类型
    public List<Type2> getTop(String sidu,String style){
        try {
            TypeMapper mapper = MyBatisUtil.get().getMapper(TypeMapper.class);
            return mapper.getTop(sidu,style);
        } finally {
            MyBatisUtil.close();
        }
    }

    public int add(Type type) {
        try {
            TypeMapper mapper = MyBatisUtil.get().getMapper(TypeMapper.class);
            int r=mapper.checkRepeat(type.getSidu(),type.getStyle());
            if(r>0)
                return 0;
            return mapper.insertSelective(type);
        } finally {
            MyBatisUtil.close();
        }
    }
}

